package cn.com.newloading.common.utils.mq;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author qja
 * @date 2021-2021/5/13-15:55
 * @describe
 */
public class MQConnectionUtil {
    public static Connection getConnection() throws IOException, TimeoutException {
        ConnectionFactory factory=new ConnectionFactory();//定义一个连接工厂
        factory.setHost("127.0.0.1");//设置服务器ַ
        factory.setPort(5672);//client端通信口
        factory.setVirtualHost("/");//vhost
        factory.setUsername("rabbit");//用户名
        factory.setPassword("rabbit");//密码
        Connection newConnection = factory.newConnection();
        return newConnection;
    }
}
